/*
 * @Author: 0x9DEFA478
 * @Date: 2025-09-20 22:19:09
 * @LastEditTime: 2025-09-21 23:00:35
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * 
 */
#ifndef hSystemUtility_C_Process_HPP_
#define hSystemUtility_C_Process_HPP_
#include "H_Pointer.hpp"
#include <string>


#if defined(_WIN32)||defined(__linux__)
namespace H{

  class Process{

    public:
      class ID{

        private:
          ID(void* privateData);
          
        public:
          ID()noexcept;
          ~ID()noexcept;

          ID(const ID& id);
          ID(ID&& id)noexcept;

          ID& operator=(const ID& id);
          ID& operator=(ID&& id)noexcept;
          
          bool Valid()const noexcept;

          usize Number()const noexcept;
          bool ValidNumber()const noexcept;

          std::string String()const noexcept;
          bool ValidString()const noexcept;

        private:
          void* privateData;

        friend class Process;
      };

    public:
      Process()noexcept;
      Process(const H::Pointer<std::string>::Const& Command,bool UsePipeIO);
      ~Process()noexcept;

      Process(const Process&)=delete;
      Process(Process&& process)noexcept;

      Process& operator=(const Process&)=delete;
      Process& operator=(Process&& process)noexcept;

      bool WriteInput(const std::string& str)noexcept;
      H::Pointer<char> ReadOutput()noexcept;
      H::Pointer<char> ReadLine(char SplitChar='\n')noexcept;
      bool IsStop()noexcept;
      void WaitStop()noexcept;
      void Stop()noexcept;
      int Result()noexcept;

      ID GetID()const noexcept;

    private:
      void* privateData;
  };

}
#endif


#endif //hSystemUtility_C_Process_HPP_
